﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.IDao;
using Chinaer.Dao.EF;

namespace Chinaer.Dao
{
    public class ZhongXinGongGaoDAO : IZhongXinGongGaoDAO
    {
        IZhongXinGongGaoDAO zhongXinGongGao = new Chinaer.Dao.EF.ZhongXinGongGaoDAO();


        public bool EnableTrack
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public IList<Model.Entities.Model_ZhongXinGongGao> Query(string sql, int pageIndex, out int recordCount, int pageSize, params System.Data.SqlClient.SqlParameter[] sqlParams)
        {
            return zhongXinGongGao.Query(sql, pageIndex, out recordCount, pageSize, sqlParams);
        }

        public Model.Entities.Model_ZhongXinGongGao GetByID(string id)
        {
            return zhongXinGongGao.GetByID(id);
        }

        public bool Exists(string id)
        {
            return zhongXinGongGao.Exists(id);
        }

        public bool Add(Model.Entities.Model_ZhongXinGongGao entity)
        {
            return zhongXinGongGao.Add(entity);
        }

        public bool Update(Model.Entities.Model_ZhongXinGongGao entity)
        {
            return zhongXinGongGao.Update(entity);
        }

        public bool Delete(Model.Entities.Model_ZhongXinGongGao entity)
        {
            return zhongXinGongGao.Delete(entity);
        }

        public bool Delete(string id)
        {
            Model.Entities.Model_ZhongXinGongGao zhongXinGongGao = GetByID(id);
            return Delete(zhongXinGongGao);
        }

        public int DeleteByIDs(IList<string> listID)
        {
            return zhongXinGongGao.DeleteByIDs(listID);
        }

        public List<Model.Entities.Model_ZhongXinGongGao> GetAllZhongXinGongGao()
        {
            using (ChinaerContext context = ChinaerContext.GetNewInstance())
            {
                return context.ZhongXinGongGaos.Where(z => z.IsDelete == false && z.IsUse == true).ToList();
            }
        }

        public List<Model.Entities.Model_ZhongXinGongGao> GetZhongXinGongGaoByTimeSpan(DateTime beginTime, DateTime endTime)
        {
            using (ChinaerContext context = ChinaerContext.GetNewInstance())
            {
                return context.ZhongXinGongGaos.Where(z => z.EndTime >= beginTime && z.EndTime <= endTime).ToList();
            }
        }
    }
}
